﻿import QtQuick 2.0

import QtQuick.Window 2.12
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.1
import "../components"

Window {
    id: root

    title: qsTr("混合判定")

    minimumWidth: 420*dp
    minimumHeight: 400*dp
    maximumWidth: 420*dp
    maximumHeight: 400*dp

    flags: Qt.Window | Qt.WindowTitleHint |Qt.WindowSystemMenuHint | Qt.WindowCloseButtonHint
    modality: Qt.WindowModal

    onVisibleChanged: {
        if(!visible) return
        var res = CSetUp.getHhpd()
        edit_R1.text = res[0]["Num"]
        edit_R2.text = res[1]["Num"]
        edit_R3.text = res[2]["Num"]
        edit_X1.text = res[3]["Num"]
    }

    Column{
        x: 20*dp
        y: 20*dp
        Rectangle{
            color: "#EBEDF0"
            height: 60*dp
            width: 380*dp
            Rectangle{
                color: "#F7F8FA"
                height: 60*dp-1;    width: 190*dp-1
                x:1;                y:1
                Text {
                    text: "参数"
                    anchors.centerIn: parent
                }
            }Rectangle{
                color: "#F7F8FA"
                x: 190*dp+1;        y: 1
                height: 60*dp-1;    width: 190*dp-2
                Text {
                    text: "值"
                    anchors.centerIn: parent
                }
            }
        }Rectangle{
            color: "#EBEDF0"
            height: 50*dp
            width: 380*dp
            Rectangle{
                height: 50*dp-1;    width: 190*dp-1
                x:1;                y:1
                Text {
                    text: "R1"
                    anchors.centerIn: parent
                }
            }Rectangle{
                x: 190*dp+1;        y: 1
                height: 50*dp-1;    width: 190*dp-2
                clip: true
                TextInput {
                    id: edit_R1
                    anchors.fill: parent
                    verticalAlignment: TextInput.AlignVCenter
                    horizontalAlignment: TextInput.AlignHCenter
                }
            }

        }Rectangle{
            color: "#EBEDF0"
            height: 50*dp
            width: 380*dp
            Rectangle{
                height: 50*dp-1;    width: 190*dp-1
                x:1;                y:1
                Text {
                    text: "R2"
                    anchors.centerIn: parent
                }
            }Rectangle{
                x: 190*dp+1;        y: 1
                height: 50*dp-1;    width: 190*dp-2
                clip: true
                TextInput {
                    id: edit_R2
                    anchors.fill: parent
                    verticalAlignment: TextInput.AlignVCenter
                    horizontalAlignment: TextInput.AlignHCenter
                }
            }

        }Rectangle{
            color: "#EBEDF0"
            height: 50*dp
            width: 380*dp
            Rectangle{
                height: 50*dp-1;    width: 190*dp-1
                x:1;                y:1
                Text {
                    text: "R3"
                    anchors.centerIn: parent
                }
            }Rectangle{
                x: 190*dp+1;        y: 1
                height: 50*dp-1;    width: 190*dp-2
                clip: true
                TextInput {
                    id: edit_R3
                    anchors.fill: parent
                    verticalAlignment: TextInput.AlignVCenter
                    horizontalAlignment: TextInput.AlignHCenter
                }
            }
        }Rectangle{
            color: "#EBEDF0"
            height: 50*dp
            width: 380*dp
            Rectangle{
                height: 50*dp-2;    width: 190*dp-1
                x:1;  y:1
                Text {
                    text: "X1"
                    anchors.centerIn: parent
                }
            }Rectangle{
                x: 190*dp+1;        y: 1
                height: 50*dp-2;    width: 190*dp-2
                clip: true
                TextInput {
                    id: edit_X1
                    anchors.fill: parent
                    verticalAlignment: TextInput.AlignVCenter
                    horizontalAlignment: TextInput.AlignHCenter
                }
            }
        }
    }

    Item{
        y: root.height - 90*dp
        width: root.width
        PushButton{
            title: "取消"
            x: root.width / 2 - 130*dp
            defaultMode2: true
            onReleased: {
                close()
            }
        }PushButton{
            title: "确定"
            x: root.width / 2 + 10*dp
            defaultMode1: true
            onReleased: {
                var res = [ {"Parameter": "R1", "Num": edit_R1.text},
                            {"Parameter": "R2", "Num": edit_R2.text},
                            {"Parameter": "R3", "Num": edit_R3.text},
                            {"Parameter": "X1", "Num": edit_X1.text} ]
                CSetUp.editHhpd(res)
                close()
            }


        }
    }


}
